package com.google.code.bbdsm.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.google.code.bbdsm.domain.*;

import com.google.code.bbdsm.service.DataSourceManager;

public class NewDataSourceController extends SimpleFormController {
	
	private DataSourceManager dataSourceManager;
	
	private Log log = LogFactory.getLog(getClass());

	public DataSourceManager getDataSourceManager() {
		return dataSourceManager;
	}

	public void setDataSourceManager(DataSourceManager dataSourceManager) {
		this.dataSourceManager = dataSourceManager;
	}
	
	protected Object formBackingObject(HttpServletRequest request) throws Exception {
		log.debug("Creating new DataSource as command for creation");
		return new DataSource();
	}
	
	protected void doSubmitAction(Object object) throws Exception {
		DataSource ds = (DataSource) object;
		dataSourceManager.create(ds);
	}
	

}
